﻿<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>就诊人管理</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="/lobsteruiframe/weui/css/weui.css" />
    <link rel="stylesheet" href="/lobsteruiframe/weui/css/weuix.css" />
    <link href="/customer/css/blue.css" rel="stylesheet" />
    <script src="/lobsteruiframe/weui/js/zepto.min.js"></script>
    <script src="/lobsteruiframe/weui/js/zepto.weui.js"></script>
    <script src="/lobsteruiframe/weui/js/php.js"></script>
    <script src="/jslib/template-web.js"></script>
    <script src="/jslib/lobster.js"></script>

    <style type="text/css">

        .label {
            padding: 2px 10px;
        }

        .icon {
            font-size: 24px;
            line-height: 40px;
            margin: 5px 0;
            color: #07c160;
            -webkit-transition: font-size 0.5s ease-out 0s;
            -moz-transition: font-size 0.5s ease-out 0s;
            transition: font-size 0.5s ease-out 0s;
            width: 20px;
            height: 20px;
        }

        button[size=mini] {
            font-size: 17px;
            padding: 0 10px;
        }

        .add_btn {
            width: 100%;
            height: 60px;
            text-align: center;
            background-color: #fff;
            font-size: 17px;
            position: fixed;
            bottom: 0px;
            border-top: 1px #f5f5f5 solid;
            box-sizing: border-box;
        }

            .add_btn .btn2 {
                margin: 10px 25px;
                height: 40px;
                line-height: 40px;
                background-color: #07c160;
                color: #fff;
                border-radius: 20px;
                box-sizing: border-box;
            }

        .red-bb {
            border: 1px #ff0000 solid;
        }
    </style>


</head>

<body ontouchstart class="page-bg">
    <div class="page-bd" id="maincontent">
        <div id="patlist" style=" padding-bottom: 70px; "></div>       
    </div>

    <div class="add_btn">
        <div class="btn2">+添加就诊人</div>
    </div>
</body>
</html>

<script>

    lobsterh5.main({
        data: {
        },
        //初始化页面
        pageload: function () {
            this.getpatient();
        },
        //初始化事件
        initevent: function () {
            var self = this;           
            //设为默认
            $(".setdefault").click(function (obj) {
                var PatientId = $(this).data("info");
                self.setdefault(PatientId);
            });
            //删除
            $(".deletepatient").click(function (obj) {
                var PatientId = $(this).data("info");
                $.confirm("您确定要删除吗?", "确认删除?", function () {
                    self.deletepatient(PatientId);
                }, function () {
                    //取消操作
                });
            });

            //绑卡
            $(".bindcard").click(function (obj) {
                var PatientId = $(this).data("info");
                location.href = "cardlist.html?patientId=" + PatientId;
            });
            //实名认证
            $(".smrz").click(function (obj) {
                let patientId = $(this).data("info");
                location.href = "verify.html?patientId=" + patientId;
            });

            //添加就诊人
            $(".add_btn").on('click', ".btn2", function () {
                console.log("add_btn")
                location.href = "addpatient.html";
            });  
            //查看就诊人详情
            $(".patientitem").click(function (obj) {
                var PatientId = $(this).data("info");
                location.href = "detail.html?patientId=" + PatientId;
            })
        },
        //获取就诊人列表
        getpatient: function () {
            var self = this;

            lobsterh5.GET("/admin/v1/CPatient/GetUserPatient").then(data => {
                if (data.patdata) {
                    self.inittemp("tplpatient", "patlist", { list: data.patdata });

                    self.initevent();
                }
            }).catch(res => {
                console.log(res);
            });
        },
        inittemp: function (tempid, _id, data) {
            var html = template(tempid, data);
            $("#" + _id).html(html);
        },
        //删除病人
        deletepatient: function (patientId) {
            var self = this;
            lobsterh5.GET("/admin/v1/CPatient/DeletePatient", { patientId: patientId }).then(data => {
                self.getpatient();
            }).catch(res => {
                console.log(res);
            });
        },
        //设置默认就诊人
        setdefault: function (patientId) {
            var self = this;
            lobsterh5.GET("/admin/v1/CPatient/SetPatientDefault", { patientId: patientId }).then(data => {
                if (data.flag) {
                    self.getpatient();
                }
            }).catch(res => {
                console.log(res);
            });
        }
    });

</script>


<script type="text/template" id="tplpatient">
    {{if(list.length>0)}}
    {{each list }}
    <div style="margin-top: 5px;clear: both;" class="weui-panel weui-panel_access" >
        <div class="weui-panel__hd patientitem" data-info="{{$value.PatientId}}">
            <div class="weui-flex">
                <div class="weui-flex__item" style="color:#333">
                    <div class="weui-flex " >
                        <div class=" weui-media-box__title " >
                            <label>{{$value.Name}}</label>
                        </div>
                        {{ if($value.DefaultFlag==1) }}
                        <div class="weui-flex__item " style=" margin-left: 10px;display: flex;align-items: center;">
                            <label class="label f-green b-green">
                                默认
                            </label>
                        </div>
                        {{/if}}
                    </div>
                </div>
                <div class="weui-flex__item " style="text-align:right; ">
                    <label class="label f-green b-green">
                        {{ if($value.IsYB>0) }}
                        医保
                        {{else}}
                        非医保
                        {{/if}}
                    </label>
                </div>
            </div>
        </div>
        <div class="weui-panel__bd itemdata" style="border-bottom: 1px solid #eee;" data-info="{{$value.PatientId}}">
            <a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg " >
                <div class="weui-media-box__bd " >
                    <p class="page-hd-desc padding-2">
                        <div class="weui-flex page-hd-desc">
                            <text style="width:70%">
                                证件类型：{{$value.CardTypeName}}
                            </text>
                        </div>
                        <div class="weui-flex page-hd-desc">
                            <text style="width:70%">
                                证件号码：{{$value.cardNo}}
                            </text>
                            {{ if($value.IDCardType=='01')}}

                            <div style="text-decoration:underline" class="smrz  weui-flex__item {{$value.DetectFlag==0?'orange-color':'green-color'}}"
                                    data-info="{{$value.PatientId}}">
                                {{$value.DetectFlag==0?'未实名认证':$value.DetectFlag==1?'已实名认证':'已实人认证'}}
                            </div>

                            {{/if}}
                        </div>
                        <div class="weui-flex page-hd-desc">
                            <text style="width:70%">绑卡数量：{{$value.CardNum}} </text>
                            <div style="text-decoration:underline;" class="weui-flex__item  green-color bindcard" data-info="{{$value.PatientId}}">绑卡</div>
                        </div>

                    </p>

                </div>
            </a>
        </div>
        <div class="weui-panel__hd actiondiv" style="    text-align: right;  margin-right: 10px;padding:5px;height: 30px;">
            <div class="blue-bplb-button blue-rt red-bd white-color deletepatient" data-info="{{$value.PatientId}}">删除</div>

            {{ if($value.DefaultFlag==0) }}
            <div class="blue-bplb-button blue-rt white-bd red-color red-bb setdefault" data-info="{{$value.PatientId}}">设为默认</div>
            {{/if}}
        </div>
    </div>
    {{/each}}
    {{else}}
    <div class="weui-loadmore weui-loadmore_line">
        <span class="weui-loadmore__tips">暂无数据</span>
    </div>
    {{/if}}
</script>